<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layuiAdmin 网站用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<style>
    .layui-table-cell {
        height: inherit;
    }
</style>
<body>
<div class="layui-fluid">
    <fieldset class="layui-elem-field">
        <legend>拼团列表</legend>
        <div class="layui-field-box">
            <div class="layui-card">

                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">开团时间</label>
                            <div class="layui-input-inline" style="width: 300px;">
                                <input type="text" class="layui-input" name="time" id="test10" placeholder=" - ">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">活动状态</label>
                            <div class="layui-input-inline">
                                <select name="status" lay-verify="">
                                    <option value="">全部</option>
                                    <option value="1">进行中</option>
                                    <option value="2">已完成</option>
                                    <option value="3">未完成</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list layui-btn-normal" lay-submit lay-filter="LAY-app-contlist-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body">
                    <table id="demo" lay-filter="demo"></table>
                    <script type="text/html" id="table-content-list">
                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="look"><i class="layui-icon"></i>查看成员</a>
                    </script>
                </div>
            </div>
        </div>
    </fieldset>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate', 'common'], function(){
        var $ = layui.$,
                common = layui.common,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate;

        //日期时间范围
        laydate.render({
            elem: '#test10'
            ,type: 'datetime'
            ,range: true
        });

        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('demo', {
                url: "{:url('Market/spell_order')}",
                where: field,
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //执行渲染
        table.render({
            elem: '#demo',
            url: "{:url('Market/spell_order')}",
            method: 'post',
            cols: [[
                {field: 'username', title: '开团团长'},
                {field: 'name', title: '拼团产品'},
                {field: 'num', title: '成团人数', templet: function (d){ return d.num + '人'; }},
                {field: 'count', title: '参加人数', templet: function (d){ return d.count + '人'; }},
                {field: 'start_time', title: '开团时间', templet: function (d){ return common.formatDateTime(d.start_time); }},
                {field: 'end_time', title: '结束时间', templet: function (d){ return common.formatDateTime(d.end_time); }},
                {field: 'status', title: '状态'},
                {title: '操作', width: 150, align:'center', toolbar: '#table-content-list'}
            ]],
            page: {
                limits: [10, 20, 30, 40, 50]
            }
        });

        //监听事件
        table.on('tool(demo)', function(obj){
            var id = obj.data.id;
            var layEvent = obj.event;
            if(layEvent === 'look'){ //查看成员
                var spell_number = obj.data.spell_number;
                layer.open({
                    type: 2,
                    title: '数据',
                    content: '/admin/Market/spell_order_operate/spell_number/' + spell_number,
                    maxmin: true,
                    area: ['100%', '100%'],
                    btn: '关闭',
                    btnAlign: 'c',
                    yes: function(index, layero){
                        //点击确认触发 iframe 内容中的按钮提交
                        layer.close(index);
                    }
                });
            }
        });
    });
</script>
</body>
</html>
